#include <iostream>
#include <cmath>

using namespace std;

int main(){
	int n;
	cin >> n;
	int d= 0;
	int n2 = 0;
	for(int j = 1;j <= n;j++){
		if (n%j==0){
			int a =0 ,b = 0;
			int n3 = 0;
			while(pow(10,n3) <= j){
			    b += (int)(j / pow(10,n3)) % 10;
			    n3 += 1;
			}
			if (b == j/2){
			    d += 1;
			}
		}
	}
	cout << d;
}

